package com.xiaoma.pattern.proxy.pre;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JdbcDynamicalProxy implements InvocationHandler {

    private Subject subject;

    public JdbcDynamicalProxy(Subject subject) {
        this.subject = subject;
    }

    @Override
    public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
        System.out.println(method.getName()+" 前");
        Object result = method.invoke(subject, objects);
        System.out.println(method.getName()+" 后");
        return result;
    }

}
